import React, {Component} from 'react'
import styles from './book.less'
import Card from "./components/card"
import isEmpty from 'lodash/isEmpty'
import { connect } from 'dva';
import {GET_BOOK_LIST} from '../../actions/book';

@connect(({ book }) => ({
  book
}))

class Book extends Component{
  constructor(props) {
    super(props);
  }

  componentDidMount() {
    const {dispatch} = this.props
    dispatch(GET_BOOK_LIST())
  }

  render() {
    const {book: { bookList }} = this.props
    return (
      <div style={{paddingBottom: 146}} className={styles.courseContainer}>
        {
          !isEmpty(bookList) && bookList.map((book, bookIndex) => {
            return <Card cardInfo={book} index={bookIndex} key={book.id}/>
          })
        }
      </div>
    );
  }
}



export default Book
